package nc.bs.pub.action;

import java.util.ArrayList;
import java.util.Hashtable;

import nc.bs.pub.compiler.AbstractCompiler2;
import nc.vo.pr.pub.HYBillVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.compiler.PfParameterVO;
import nc.vo.pub.lang.UFDouble;
import nc.vo.uap.pf.PFBusinessException;

public class N_9566_WRITE extends AbstractCompiler2
{
  private Hashtable m_methodReturnHas = new Hashtable();
  private Hashtable m_keyHas = null;

  public Object runComClass(PfParameterVO vo)
    throws BusinessException
  {
    try
    {
      this.m_tmpVo = vo;

      Object retObj = null;
      
      retObj = runClass("nc.bs.pr.pub.HYBillSave", "saveBill", "nc.vo.pub.AggregatedValueObject:01", vo, this.m_keyHas, this.m_methodReturnHas);

      HYBillVO hybillvo = (HYBillVO)(HYBillVO)((ArrayList)retObj).get(1);

      setParameter("hybillvo", hybillvo);
      runClass("nc.bs.pr.pr202010.YjcdrecAnswerWrite", "saveAnswer", "&hybillvo:nc.vo.pr.pub.HYBillVO", vo, this.m_keyHas, this.m_methodReturnHas);
      
      //add by zl start
      //reserve5:优惠方式，reserve6：优惠金额
      if(hybillvo.getParentVO().getAttributeValue("reserve6") != null && !"".equals(hybillvo.getParentVO().getAttributeValue("reserve6"))
    		  && new UFDouble(hybillvo.getParentVO().getAttributeValue("reserve6").toString()).doubleValue() > 0){
    	  runClass("nc.bs.pr.pr202010.YjcdrecAnswerWrite", "yhcd", "&hybillvo:nc.vo.pr.pub.HYBillVO", vo, this.m_keyHas, this.m_methodReturnHas);
      }
      
      //add by zl end
      return retObj;
    } catch (Exception ex) {
      if (ex instanceof BusinessException) {
        throw ((BusinessException)ex);
      }
      throw new PFBusinessException(ex.getMessage(), ex);
    }
  }

  public String getCodeRemark()
  {
    return "\t//####本脚本必须含有返回值,返回DLG和PNL的组件不允许有返回值####\n\tObject retObj =null;\n\t//####重要说明：生成的业务组件方法尽量不要进行修改####\n\t//方法说明:公共保存方法\n\tretObj =runClassCom@ \"nc.bs.pr.pub.HYBillSave\", \"saveBill\", \"nc.vo.pub.AggregatedValueObject:01\"@;\n\t//##################################################\n\t// 注释 by pangyongjie\n\t//nc.bs.pr.pr202010.YjcdrecAnswerWrite yaw = new nc.bs.pr.pr202010.YjcdrecAnswerWrite();\n\tnc.vo.pr.pub.HYBillVO hybillvo = ( nc.vo.pr.pub.HYBillVO )(((java.util.ArrayList)retObj).get(1));\n\t//yaw.saveAnswer(hybillvo);\n\tsetParameter(\"hybillvo\", hybillvo);\n\trunClassCom@\"nc.bs.pr.pr202010.YjcdrecAnswerWrite\", \"saveAnswer\", \"&hybillvo:nc.vo.pr.pub.HYBillVO\"@;\n\treturn retObj;\n";
  }

  private void setParameter(String key, Object val)
  {
    if (this.m_keyHas == null) {
      this.m_keyHas = new Hashtable();
    }
    if (val != null)
      this.m_keyHas.put(key, val);
  }
}